package yxxy.c_025;

import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.List;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;

public class T04_ConcurrentQueue {
    public static void main(String[] args) {
        Queue<String> strs = new ConcurrentLinkedQueue<>();
        Queue<String> strArr = new ArrayDeque<>();

        for(int i=0; i<10; i++) {
            strs.offer("a" + i);  //类似于add，但是add方法在添加时会出问题抛异常，而offer添加完成后会有一个返回值判断是否添加成功
        }

        System.out.println(strs);

        System.out.println(strs.size());

        System.out.println(strs.poll()); //poll取出并从队列中删掉
        System.out.println(strs.size());

        System.out.println(strs.peek());//peek取出但不会从队列中删掉
        System.out.println(strs.size());

        //双端队列Deque
    }
}
